<template>
    <el-dialog width="1500px" title="公证信息" :visible.sync="dialogVisible" :close-on-click-modal="false">
        <el-form class="base_form" :model="submitForm" :rules="rules" ref="ruleForm" label-width="200px">
        <el-descriptions :colon=false class="margin-top" title="用户身份信息" :column="2" :size="size">
            <el-descriptions-item>
                <el-form-item label="用户身份证正面" prop="photo">
                  <crop-upload show-type="photo" :init-val="submitForm.photo" :three-type="true" wrapper-width="95px" wrapper-height="95px" @setVal="(val) => setUrl('photo', val)" />
                </el-form-item>
            </el-descriptions-item>
            <el-descriptions-item>
                <el-form-item label="用户身份证反面" prop="f_photo">
                  <crop-upload show-type="photo" :init-val="submitForm.f_photo" wrapper-width="95px" wrapper-height="95px" @setVal="(val) => setUrl('f_photo', val)" />
                </el-form-item>
            </el-descriptions-item>
        </el-descriptions>
        <el-descriptions :colon=false class="margin-top" title="商户身份信息" :column="2" :size="size">
            <el-descriptions-item>
                <el-form-item label="法人身份证正面" prop="s_photo">
                  <crop-upload show-type="photo" :init-val="submitForm.s_photo" :three-type="true" wrapper-width="95px" wrapper-height="95px" @setVal="(val) => setUrl('s_photo', val)" />
                </el-form-item>
            </el-descriptions-item>
            <el-descriptions-item>
                <el-form-item label="法人身份证反面" prop="s_photo_f">
                  <crop-upload show-type="photo" :init-val="submitForm.s_photo_f" :three-type="true" wrapper-width="95px" wrapper-height="95px" @setVal="(val) => setUrl('s_photo_f', val)" />
                </el-form-item>
            </el-descriptions-item>
            <el-descriptions-item>
                <el-form-item label="营业执照" prop="s_photo_f1">
                  <crop-upload show-type="photo" :init-val="submitForm.s_photo_f1" :three-type="true" wrapper-width="95px" wrapper-height="95px" @setVal="(val) => setUrl('s_photo_f1', val)" />
                </el-form-item>
            </el-descriptions-item>
            <el-descriptions-item>
                <el-form-item label="法人身份证明" prop="s_photo_f2">
                  <crop-upload show-type="photo" :init-val="submitForm.s_photo_f2" :three-type="true" wrapper-width="95px" wrapper-height="95px" @setVal="(val) => setUrl('s_photo_f2', val)" />
                </el-form-item>
            </el-descriptions-item>
        </el-descriptions>
    </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button size="small" @click="dialogVisible = false">取 消</el-button>
        <el-button size="small" type="primary" @click="submit">确 定</el-button>
      </div>
    </el-dialog>
  </template>
  
  <script>
  import previewImg from '@/components/previewImg'
  import cropUpload from '@/components/cropUpload'
  import { upload2 } from '@/api/index'
  import { getOrderLeaseImg } from '@/api/order'
  export default {
    components: { previewImg,cropUpload },
    props: {
      orderId: {
        type: String,
        default: ''
      }
    },
    data() {
      return {
        submitForm: {
            photo:'',
            f_photo:'',
            s_photo:'',
            s_photo_f:'',
            s_photo_f1:'',
            s_photo_f2:''

        },
        params:{},
        dialogVisible: false
      }
    },
    watch: {
      dialogVisible(val) {
      if (val) {
        getOrderLeaseImg(this.orderId).then(res=>{
          // this.submitForm.photo=res.idcard_back
          // this.submitForm.f_photo=res.idcard_front
          // this.submitForm.s_photo=res.faidcard
          // this.submitForm.s_photo_f=res.faidcard_back
          // this.submitForm.s_photo_f1=res.shopcard
          // this.submitForm.s_photo_f2=res.shopcard
        })
      } else {
        this.$refs['ruleForm'].resetFields()
      }
    }
    },
    methods: {
      setUrl(key, value) {
      this.submitForm[key] = value
    },
      submit() {
        let that =this
        this.$refs['ruleForm'].validate((valid) => {
          if (valid) {
            
            const fd = new FormData()
            fd.append('file', that.params.flie)
            upload(fd).then(res=>{
            })

          } else {
            this.$message({
              message: '请检查表单错误',
              type: 'error'
            })
            return false
          }
        })
      }
    }
  }
  </script>
  
  <style lang="scss" scoped>
  </style>
  